package com.el.logger;

public class StandardLogFormatter {

    public String format(EventLogEntry entry) {
        
        StringBuilder result = new StringBuilder();
        
        result.append("|");
        result.append(entry.getAction().getCode()).append("|");
        result.append(entry.getTimestamp()).append("|");
        result.append(entry.getThreadId()).append("|");
        result.append(entry.getEventId()).append("|");
        
        if (entry.getParams() != null) {
            result.append(entry.getParams());
        }
        
        result.append("|");
        
        if (entry.getException() != null) {
            result.append(entry.getException()+ "\n");
            Throwable t = entry.getException();
            for (int i=0; i < t.getStackTrace().length; i++)
                result.append(" at " +  t.getStackTrace()[i] + "\n");
        }
        
        return result.toString();
    }
    
    
}
